<template>
  <div class="index-container">
    <RayTable ref="table" :menu="menu" data_object_no="dicts" :height="tableHeight" :is_permission="false">
      <template #head_btn_append>
        <el-button type="success" round @click="updateDicts">更新字典</el-button>
      </template>
    </RayTable>
  </div>
</template>

<script>
  import RayTable from '@/views/template/components/rayTable.vue'
  import { updateDicts } from '@/api/template/common.js'

  export default {
    name: 'Dicts',
    components: {
      RayTable
    },
    data() {
      return {}
    },
    watch: {

    },
    created() {
      this.menu = {}
      this.tableHeight = document.documentElement.clientHeight - 250
    },
    methods: {
      updateDicts() {
        this.$confirm('确认要更新字典吗，手动添加的字典也会被清除！', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$refs.table.loading = true
          updateDicts().then(res =>{
            this.$message({
              type: 'success',
              message: res.msg
            });
            this.$refs.table.query()
          }).finally(e => {
            this.$refs.table.loading = false
          })
        })
      }
    }
  }
</script>

<style></style>
